<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let num = Math.floor(Math.random() * 100);

        let xxm = 8;
        while (xxm > 0) {
            let guess = +prompt("请猜一个数：");
            if (guess > num) {
                alert("猜大了");
                xxm--;
            } else if (guess < num) {
                alert("猜小了");
                xxm--;
            } else {
                alert("恭喜你猜对了");
                break;
            }
        }
        if (xxm === 0) {
            alert("ok");
        }
    </script>
</body>
</html>